<?
// INCLUI O ARQUIVO DE FUNCOES
require_once('../../includes/config.php');
require_once('../../includes/functions.php');

// CONECTA NO BANCO DE DADOS
$conn = connect();

// PEGA OS DADOS DA TASK
$task = select(
	'tasks t',
	array( 't.name','t.idHistory','t.idStatus','t.idUser','t.text' ),
	array( 't.id = '.$_REQUEST['id'] )
);

// TODO: Pegar dados da tabela de status
// MONTA O ARRAY DE STATUS
$status = array(
	1 => 'Todo',
	2 => 'Wip',
	3 => 'Done'
);

// PEGA OS USUARIOS
$users = select(
	'users u',
	array( 'u.id','u.name' )
);
?>
<form method="post" onsubmit="return Save.task();">
	<input type="hidden" name="action" value="edtTask" />
	<input type="hidden" name="id" value="<?= $_REQUEST['id']; ?>" />
	<div class="response"></div>

	<label for="idUser">Nome:</label><br />
	<?= mountSelect( $users['data'],'idUser',$task['data'][0]['idUser'] ); ?>

	<br /><br />

	<label for="status">Status:</label>
	<span><?= $status[ $task['data'][0]['idStatus'] ];?></span>

	<br /><br />

	<label for="text">Descrição:</label><br />
	<textarea name="text" rows="5"><?= $task['data'][0]['text']; ?></textarea>

	<br />

	<input type="submit" value="Salvar" />
</form>

<br />
